<template>
  <el-dialog title="查询条件设置" :visible.sync="dialogVisible" top="8vh" :before-close="cancel">
    <el-form :model="file" label-width="80px">
      <el-form-item label="文件名">
        <el-input v-model="file.fileName"></el-input>
      </el-form-item>
      <el-form-item label="文件主题">
        <el-input v-model="file.fileTheme"></el-input>
      </el-form-item>
      <el-form-item label="关键字">
        <el-input v-model="file.fileKeyWord"></el-input>
      </el-form-item>
      <el-form-item label="创建者">
        <el-select v-model="file.userId" filterable>
          <el-option v-for="item in user"
                     :key="item.userId"
                     :label="item.userName"
                     :value="item.userId"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="创建日期">
        <el-col :span="11">
          <el-date-picker type="date" placeholder="选择日期" v-model="file.startDate" value-format="yyyy-MM-dd"
                          style="width: 100%;"></el-date-picker>
        </el-col>
        <el-col class="line" :span="2" style="text-align: center;">至</el-col>
        <el-col :span="11">
          <el-date-picker type="date" placeholder="选择日期" v-model="file.endDate" value-format="yyyy-MM-dd"
                          style="width: 100%;"></el-date-picker>
        </el-col>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button type="primary" @click="sure">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import {userService} from '../../../service/userService'

  // TODO 查询功能待完善
  export default {
    name: 'searchDialog',
    data () {
      return {
        file: {},
        user: {}
      }
    },
    props: {
      dialogVisible: {
        type: Boolean,
        default: function () {
          return false
        }
      }
    },
    mounted () {
      this.findAllUser()
    },
    methods: {
      cancel () {
        this.$emit('cancel')
      },
      sure () {
        this.$emit('sure', this.file)
        this.file = {}
      },
      findAllUser () {
        userService.findAllUser().then(res => {
          this.user = res.data.data
        }).catch(error => {
          console.log(error)
        })
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>
